<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Home</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content=""/>
    <meta name="keywords" content=""/>
    <meta name="author" content=""/>
    <!-- Facebook and Twitter integration -->
    <meta property="og:title" content=""/>
    <meta property="og:image" content=""/>
    <meta property="og:url" content=""/>
    <meta property="og:site_name" content=""/>
    <meta property="og:description" content=""/>
    <meta name="twitter:title" content=""/>
    <meta name="twitter:image" content=""/>
    <meta name="twitter:url" content=""/>
    <meta name="twitter:card" content=""/>

<!--    <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,700" rel="stylesheet">-->

    <!-- Animate.css -->
    <link rel="stylesheet" href="css/animate.css">
    <!-- Icomoon Icon Fonts-->
    <link rel="stylesheet" href="css/icomoon.css">
    <!-- Themify Icons-->
    <link rel="stylesheet" href="css/themify-icons.css">
    <!-- Bootstrap  -->
    <link rel="stylesheet" href="css/bootstrap.css">

    <!-- Magnific Popup -->
    <link rel="stylesheet" href="css/magnific-popup.css">

    <!-- Owl Carousel  -->
    <link rel="stylesheet" href="css/owl.carousel.min.css">
    <link rel="stylesheet" href="css/owl.theme.default.min.css">

    <!-- Theme style  -->
    <link rel="stylesheet" href="css/style.css">

    <!-- Modernizr JS -->
    <script src="js/modernizr-2.6.2.min.js"></script>
    <!-- FOR IE9 below -->
    <!--[if lt IE 9]>
    <script src="js/respond.min.js"></script>
    <![endif]-->

</head>
<body>

<div class="gtco-loader"></div>

<div id="page">

    <div class="page-inner">
        <nav class="gtco-nav" role="navigation">
            <div class="gtco-container">

                <div class="row">
                    <div class="col-sm-4 col-xs-12">
                        <div id="gtco-logo"><a href="index.html">饱了吗<em>.</em></a></div>
                    </div>
                    <div class="col-xs-8 text-right menu-1">
                        <ul>
                            <li class="btn-cta"><a href="index_store.html"><span>我是商家</span></a></li>
                        </ul>
                    </div>
                </div>

            </div>
        </nav>

        <header id="gtco-header" class="gtco-cover" role="banner" style="background-image: url(images/index.jpg)">
            <div class="overlay"></div>
            <div class="gtco-container">
                <div class="row">
                    <div class="col-md-12 col-md-offset-0 text-left">


                        <div class="row row-mt-15em">
                            <div class="col-md-7 mt-text animate-box" data-animate-effect="fadeInUp">
                                <span class="intro-text-small">Welcome</span>
                                <h1>Welcome to our Ordering system</h1>
                            </div>
                            <div class="col-md-4 col-md-push-1 animate-box" data-animate-effect="fadeInRight">
                                <div class="form-wrap">
                                    <div class="tab">
                                        <ul class="tab-menu">
                                            <li class="active gtco-first"><a href="#" data-tab="signup">注册</a></li>
                                            <li class="gtco-second"><a href="#" data-tab="login">登录</a></li>
                                        </ul>
                                        <div class="tab-content">
                                            <div class="tab-content-inner active" data-content="signup">
                                                <form action="#">
                                                    <div class="row form-group">
                                                        <div class="col-md-12">
                                                            <label for="registeruser">用户名</label>
                                                            <input type="text" class="form-control" id="registeruser"><br/>
                                                            <div id = "div1" hidden>
                                                                <span id = "caution"></span><br>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="row form-group">
                                                        <div class="col-md-12">
                                                            <label for="registerpwd1">密码</label>
                                                            <input type="password" class="form-control"
                                                                   id="registerpwd1">
                                                        </div>
                                                    </div>
                                                    <div class="row form-group">
                                                        <div class="col-md-12">
                                                            <label for="registerpwd2">确认密码</label><br/>
                                                            <input type="password" class="form-control"
                                                                   id="registerpwd2">
                                                            <div id = "div2" hidden>
                                                                <span id = "cautionpwd"></span><br>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="row form-group">
                                                        <div class="col-md-12">
                                                            <label for="registerphone">手机:</label>
                                                            <input type="text" class="form-control" id="registerphone">
                                                        </div>
                                                    </div>

                                                    <div class="row form-group">
                                                        <div class="col-md-12">
                                                            <input type="reset" class="btn btn-primary" value="重置">&emsp;&emsp;&emsp;&emsp;
                                                            <input type="button" class="btn btn-primary" id="register" value="注册">
                                                        </div>
                                                    </div>
                                                </form>
                                            </div>

                                            <div class="tab-content-inner" data-content="login">
                                                <form action="#">
                                                    <div class="row form-group">
                                                        <div class="col-md-12">
                                                            <label for="loginuser">用户名:</label>
                                                            <input type="text" class="form-control" id="loginuser">
                                                        </div>
                                                    </div>
                                                    <div class="row form-group">
                                                        <div class="col-md-12">
                                                            <label for="loginpwd">密码:</label>
                                                            <input type="password" class="form-control" id="loginpwd">
                                                        </div>
                                                    </div>

                                                    <div class="row form-group">
                                                        <div class="col-md-12">
                                                            <input type="button" class="btn btn-primary" value="暂不登录">&emsp;&emsp;
                                                            <input type="button" class="btn btn-primary" id="login" value="登录">
                                                        </div>
                                                    </div>
                                                </form>
                                            </div>

                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </header>



    </div>
</div>
</body>
<script src="js/jquery-3.2.1.js" type="text/javascript"></script>
<!-- Bootstrap -->
<script src="js/bootstrap.min.js"></script>
<!-- Waypoints -->
<script src="js/jquery.waypoints.min.js"></script>
<!-- Carousel -->
<script src="js/owl.carousel.min.js"></script>
<!-- countTo -->
<script src="js/jquery.countTo.js"></script>
<!-- Magnific Popup -->
<script src="js/jquery.magnific-popup.min.js"></script>
<!-- Main -->
<script src="js/index.js"></script>
<script src="js/layer/layer.js" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
        $("#login").click(function () {
            if ($('#loginuser').val() == '' || $('#loginpwd').val() == '') {
                layer.msg("请输入完整信息");
                return;
            }
            $.post('user.login', {
                user: $('#loginuser').val(),
                upwd: $('#loginpwd').val()
            }, function (data) {
                if (data.code == 200) {
                    layer.msg(data.msg, {icon: 1, time: 2000}, function () {
                        sessionStorage.setItem("currentUser", JSON.stringify(data.currentUser));
                        location.href = "Managermain.html";
                    })
                } else {
                    layer.msg(data.msg);
                }
            }, 'json')

        })
        var isTrue = false;
        $('#registeruser').blur(function () {
            if($('#registeruser').val()!='') {
                $.getJSON('user.checkUser', {user: $('#registeruser').val()}, function (data) {
                    if (data.code != 200) {
                        isTrue = true;
                        $('#div1').removeAttr('hidden');
                        $('#caution').css('color', 'red');
                        $('#caution').text(data.msg);
                    } else {
                        isTrue = false;
                        $('#div1').removeAttr('hidden');
                        $('#caution').css('color', 'green');
                        $('#caution').text(data.msg);
                    }
                })
            }
        })
        var isOk=false;
        $('#registerpwd2').blur(function () {
            if($('#registerpwd1').val()!=$('#registerpwd2').val()){
                isOk=true;
                $('#div2').removeAttr('hidden');
                $('#cautionpwd').css('color','red');
                $('#cautionpwd').text('两次密码输入不一致');
            }else {
                isOk=false;
                $('#div2').attr('hidden','hidden');
            }
        })
        $('#register').click(function () {
            if($('#registeruser').val()==''||$('#registerpwd1').val()==''||$('#registerpwd2').val()==''){
                layer.msg("请输入完整信息");
                return ;
            }
            if(isTrue||isOk){
                layer.msg("注册失败");
                return;
            }
            $.post('user.register', {
                user : $('#registeruser').val(),
                upwd : $('#registerpwd1').val(),
                phone : $('#registerphone').val(),
            },function (data) {
                if(data.code==200){
                    layer.msg(data.msg,{icon:1,time:2000},function () {
                        location.href="index.html";
                    })
                }else{
                    layer.msg(data.msg);
                }
            },'json')
        })

    })
</script>
</html>

